using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using System.Text;

using EntLibEC.Cmn;
using EntLibEC.Biz.Sale;

using EntLibEC.Info.Basic;
using EntLibEC.Biz.Basic;

namespace EntLibEC.View.Init
{
	/// <summary>
	/// Summary description for WebForm1.
	/// </summary>
	public partial class WebForm1 : System.Web.UI.Page
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    

		}
		#endregion

		private void btnPaypalCost_Click(object sender, System.EventArgs e)
		{
			//Response.Write(SaleManager.GetInstance().GetPaypalShipCostDs().ToString());
		}

		protected void btnShipPriceConcatenateCheck_Click(object sender, System.EventArgs e)
		{
			DataSet ds = EntLibEC.Biz.Basic.ASPManager.GetInstance().ConcatenateCheck();
			if ( !Util.HasMoreRow(ds))
				return;

			StringBuilder sb = new StringBuilder(500);
			sb.Append("<table>");


			int last_shipTypeSysNo = AppConst.IntNull;
			int last_areaSysNo = AppConst.IntNull;
			int cur_shipTypeSysNo = AppConst.IntNull;
			int cur_areaSysNo = AppConst.IntNull;
			int weightCursor = 0;
			foreach(DataRow dr in ds.Tables[0].Rows)
			{
				cur_shipTypeSysNo = Util.TrimIntNull(dr["shipTypeSysNo"]);
				cur_areaSysNo = Util.TrimIntNull(dr["areaSysNo"]);

				if ( cur_shipTypeSysNo != last_shipTypeSysNo || cur_areaSysNo != last_areaSysNo)
				{
					weightCursor = 0;
					last_areaSysNo = cur_areaSysNo;
					last_shipTypeSysNo = cur_shipTypeSysNo;
				}

				int baseWeight = Util.TrimIntNull(dr["baseWeight"]);
				int topWeight = Util.TrimIntNull(dr["TopWeight"]);

				if ( baseWeight == weightCursor )
					weightCursor = topWeight;
				else
				{
					ShipTypeInfo shipInfo = ASPManager.GetInstance().LoadShipType( cur_shipTypeSysNo );
					AreaInfo areaInfo = ASPManager.GetInstance().LoadArea( cur_areaSysNo );
					sb.Append("<tr><td>").Append(Util.TrimIntNull(dr["sysno"]).ToString()).Append("</td><td>").Append( shipInfo.ShipTypeName ).Append("</td><td>").Append(areaInfo.GetWholeName()).Append("</td></tr>");
				}
			}
			sb.Append("</table>");

			Response.Write(sb.ToString());
		}

		private void Button1_Click(object sender, System.EventArgs e)
		{
			Hashtable ht = new Hashtable();
			ht.Add("StockSysNo", 1);
			DataSet ds = EntLibEC.Biz.Report.ReportManager.GetInstance().GetInventoryDs(ht);
			Util.DataTableToExcel(ds.Tables[0], "1.xls");
		}

		private void Button2_Click(object sender, System.EventArgs e)
		{
			EntLibEC.Biz.Statistic.StatisticManager.GetInstance().DailyPMStockSendMail();
		}
	}
}
